#region Copyright
//Copyright 2008 PivDev

//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at

//   http://www.apache.org/licenses/LICENSE-2.0

//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License. 
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;

namespace CRMAddin
{
    /// <summary>
    /// Field with linking
    /// </summary>
    [DefaultPropertyAttribute("Name")]
    public class propertyFKField
    {
        private string _Name;
        private string _DictName;
        private string _Type;
        private string _Length;
        private string _LinkedTable;
        private object _LinkedTableId;
        private object _LinkedFieldId;
        private string _LinkedField;

        [CategoryAttribute("Linking"), DescriptionAttribute("FK Field Linked to"), DisplayNameAttribute("Field Linked To")]
        public string LinkedField
        {
            get { return _LinkedField; }
            set { _LinkedField = value; }
        }

        [BrowsableAttribute(false)]
        public object LinkedFieldId
        {
            get { return _LinkedFieldId; }
            set { _LinkedFieldId = value; }
        }

        [BrowsableAttribute(false)]
        public object LinkedTableId
        {
            get { return _LinkedTableId; }
            set { _LinkedTableId = value; }
        }

        [CategoryAttribute("Linking"), DescriptionAttribute("FK Field Table Linked to"), DisplayNameAttribute("Table Linked To"), DesignOnlyAttribute(true)]
        public string LinkedTable
        {
            get { return _LinkedTable; }
            set { _LinkedTable = value; }
        }
        
        [CategoryAttribute("Data Dictionary"), DescriptionAttribute("Length of Field")]
        public string Length
        {
            get { return _Length; }
            set { _Length = value; }
        }

        [CategoryAttribute("Data Dictionary"), DescriptionAttribute("DB Type"), DisplayNameAttribute("DB Type")]
        public string Type
        {
            get { return _Type; }
            set 
            {
                switch (value)
                {
                    case "0":
                        _Type = "String";
                        break;
                    case "1":
                        _Type = "Memo";
                        break;
                    case "2":
                        _Type = "Integer";
                        break;
                    case "3":
                        _Type = "Binary (RAW)";
                        break;
                    case "4":
                        _Type = "Currency (Float)";
                        break;
                    case "5":
                        _Type = "Float";
                        break;
                    case "6":
                        _Type = "Boolean";
                        break;
                    case "7":
                        _Type = "Date";
                        break;
                    case "8":
                        _Type = "Time";
                        break;
                    case "9":
                        _Type = "Timestamp";
                        break;
                    case "10":
                        _Type = "Choice (Int)";
                        break;
                    case "11":
                        _Type = "Combo (String)";
                        break;
                    case "12":
                        _Type = "OLE";
                        break;
                    case "13":
                        _Type = "BLOB";
                        break;
                }
              // _Type = value; 
            }
            
        }

        [CategoryAttribute("Data Dictionary"), DescriptionAttribute("Pivotal Type"), DisplayNameAttribute("Dictionary Name")]
        public string DictName
        {
            get { return _DictName; }
            set { _DictName = value; }


        }

        [CategoryAttribute("Description"), DescriptionAttribute("Field Name")]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }



        public propertyFKField()
        { }
    }

    /// <summary>
    /// Normal Field, no Linking
    /// </summary>
    [DefaultPropertyAttribute("Name")]
    public class propertyField
    {
        private string _Name;
        private string _DictName;
        private string _Type;
        private string _Length;
       
        [CategoryAttribute("Data Dictionary"), DescriptionAttribute("Length of Field")]
        public string Length
        {
            get { return _Length; }
            set { _Length = value; }
        }

        [CategoryAttribute("Data Dictionary"), DescriptionAttribute("DB Type"), DisplayNameAttribute("DB Type")]
        public string Type
        {
            get { return _Type; }
            set
            {
                switch (value)
                {
                    case "0":
                        _Type = "String";
                        break;
                    case "1":
                        _Type = "Memo";
                        break;
                    case "2":
                        _Type = "Integer";
                        break;
                    case "3":
                        _Type = "Binary (RAW)";
                        break;
                    case "4":
                        _Type = "Currency (Float)";
                        break;
                    case "5":
                        _Type = "Float";
                        break;
                    case "6":
                        _Type = "Boolean";
                        break;
                    case "7":
                        _Type = "Date";
                        break;
                    case "8":
                        _Type = "Time";
                        break;
                    case "9":
                        _Type = "Timestamp";
                        break;
                    case "10":
                        _Type = "Choice (Int)";
                        break;
                    case "11":
                        _Type = "Combo (String)";
                        break;
                    case "12":
                        _Type = "OLE";
                        break;
                    case "13":
                        _Type = "BLOB";
                        break;
                }
                // _Type = value; 
            }

        }

        [CategoryAttribute("Data Dictionary"), DescriptionAttribute("Pivotal Type"), DisplayNameAttribute("Dictionary Name")]
        public string DictName
        {
            get { return _DictName; }
            set { _DictName = value; }


        }

        [CategoryAttribute("Description"), DescriptionAttribute("Field Name")]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        public propertyField()
        { }
    }

    [DefaultPropertyAttribute("DispName")]
    public class propertyForm
    {
        private string _DispName;
        private string _TabEqual;
        private string _ServerName;
        private string _CSName;

        [CategoryAttribute("Scripts"), DescriptionAttribute("Name of Client Script associated with form"), DisplayNameAttribute("Client Script")]
        public string CSName
        {
            get { return _CSName; }
            set { _CSName = value; }
        }
        [CategoryAttribute("Scripts"), DescriptionAttribute("Name of Server Script associated with form"), DisplayNameAttribute("Server Script")]
        public string ServerName
        {
            get { return _ServerName; }
            set { _ServerName = value; }
        }
        [CategoryAttribute("Display"), DescriptionAttribute("Denotes whether tabs on form are dynamic or static width"), DisplayNameAttribute("Tabs Equal Width")]
        public string TabEqual
        {
            get { return _TabEqual; }
            set 
            {
                switch (value)
                {
                    case "0":
                        _TabEqual = "Yes";
                        break;
                    case "1":
                        _TabEqual = "No";
                        break;
                }
                    
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Name Displayed to user"), DisplayNameAttribute("Display Name")]
        public string DispName
        {
            get { return _DispName; }
            set { _DispName = value; }
        }

        public propertyForm()
        {
        }
    }

    [DefaultPropertyAttribute("TabName")]
    public class propertyTab
    {
        private string _TabName;
        private string _TabHidden;
        private string _Anchored;

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes whether Tab is anchored"), DisplayNameAttribute("Anchored")]
        public string Anchored
        {
            get { return _Anchored; }
            set
            {
                switch (value)
                {
                    case "0":
                        _Anchored = "Yes";
                        break;
                    case "1":
                        _Anchored = "No";
                        break;
                }
            }
        }
        [CategoryAttribute("Display"), DescriptionAttribute("Denotes whether Tab is hidden to user"), DisplayNameAttribute("Hidden")]
        public string TabHidden
        {
            get { return _TabHidden; }
            set 
            {
                switch (value)
                {
                    case "0":
                        _TabHidden = "Yes";
                        break;
                    case "1":
                        _TabHidden = "No";
                        break;
                }
            }
        }


        [CategoryAttribute("Display"), DescriptionAttribute("Internal Name of Tab"), DisplayNameAttribute("Tab Name")]
        public string TabName
        {
            get { return _TabName; }
            set { _TabName = value; }
        }
        public propertyTab()
        { }
    }

    [DefaultPropertyAttribute("SegName")]
    public class propertySegSec
    {
        private string _Shrinkable;
        private string _Secondary;
        private string _SegName;
        private string _TitleHidden;
        private string _SortDesc;
        private string _ProhAdd;
        private string _ProhDel;
        private string _ReadOnly;
        private string _InPlaceNew;
        private string _SegHidden;
        private string _SRList;
        private string _RecPerPage;
        private string _IsCollapsed;


        [CategoryAttribute("Display"), DescriptionAttribute("Denotes that the segment starts Collapsed"), DisplayNameAttribute("Collapsed")]
        public string IsCollapsed
        {
            get { return _IsCollapsed; }
            set
            {
                switch (value)
                {
                    case "1":
                        _IsCollapsed = "Yes";
                        break;
                    case "0":
                        _IsCollapsed = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Secondary"), DescriptionAttribute("Denotes the number of records to display per page"), DisplayNameAttribute("Records per Page")]
        public string RecPerPage
        {
            get { return _RecPerPage; }
            set 
            {
                if (value.Equals("0"))
                {
                    _RecPerPage = "No Limit";
                }
                else
                {
                    _RecPerPage = value;
                }
            }
        }

        [CategoryAttribute("Secondary"), DescriptionAttribute("Denotes that this is linked to Search Result List"), DisplayNameAttribute("Search Result List")]
        public string SRList
        {
            get { return _SRList; }
            set
            {
                switch (value)
                {
                    case "1":
                        _SRList = "Yes";
                        break;
                    case "0":
                        _SRList = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes that the segment is hidden"), DisplayNameAttribute("Hidden")]
        public string SegHidden
        {
            get { return _SegHidden; }
            set
            {
                switch (value)
                {
                    case "1":
                        _SegHidden = "Yes";
                        break;
                    case "0":
                        _SegHidden = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Secondary"), DescriptionAttribute("Denotes that in place adds are configured"), DisplayNameAttribute("Add in Place")]
        public string InPlaceNew
        {
            get { return _InPlaceNew; }
            set
            {
                switch (value)
                {
                    case "1":
                        _InPlaceNew = "Yes";
                        break;
                    case "0":
                        _InPlaceNew = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Secondary"), DescriptionAttribute("Denotes secondary recordset is read only"), DisplayNameAttribute("Read Only")]
        public string ReadOnly
        {
            get { return _ReadOnly; }
            set
            {
                switch (value)
                {
                    case "1":
                        _ReadOnly = "Yes";
                        break;
                    case "0":
                        _ReadOnly = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Secondary"), DescriptionAttribute("User can not delete records in secondary, irrespective of table permissions"), DisplayNameAttribute("Prohibit Delete")]
        public string ProhDel
        {
            get { return _ProhDel; }
            set
            {
                switch (value)
                {
                    case "1":
                        _ProhDel = "Yes";
                        break;
                    case "0":
                        _ProhDel = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Secondary"), DescriptionAttribute("User can not delete records in secondary, irrespective of table permissions"), DisplayNameAttribute("Prohibit Add")]
        public string ProhAdd
        {
            get { return _ProhAdd; }
            set
            {
                switch (value)
                {
                    case "1":
                        _ProhAdd = "Yes";
                        break;
                    case "0":
                        _ProhAdd = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Secondary"), DescriptionAttribute("Default sort is descending"), DisplayNameAttribute("Sort Descending")]
        public string SortDesc
        {
            get { return _SortDesc; }
            set
            {
                switch (value)
                {
                    case "1":
                        _SortDesc = "Yes";
                        break;
                    case "0":
                        _SortDesc = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes that the segment title is hidden"), DisplayNameAttribute("Title Hidden")]
        public string TitleHidden
        {
            get { return _TitleHidden; }
            set
            {
                switch (value)
                {
                    case "1":
                        _TitleHidden = "Yes";
                        break;
                    case "0":
                        _TitleHidden = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes the internal segment name"), DisplayNameAttribute("Segment Name")]
        public string SegName
        {
            get { return _SegName; }
            set { _SegName = value; }
        }

        [CategoryAttribute("Secondary"), DescriptionAttribute("This segment is a secondary"), DisplayNameAttribute("Secondary")]
        public string Secondary
        {
            get { return _Secondary; }
            set
            {
                switch (value)
                {
                    case "1":
                        _Secondary = "Yes";
                        break;
                    case "0":
                        _Secondary = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes that the segment can be collapsed"), DisplayNameAttribute("Collapsable")]
        public string Shrinkable
        {
            get { return _Shrinkable; }
            set
            {
                switch (value)
                {
                    case "1":
                        _Shrinkable = "Yes";
                        break;
                    case "0":
                        _Shrinkable = "No";
                        break;
                }
            }
        }
    }

    [DefaultPropertyAttribute("SegName")]
    public class propertySeg
    {
        private string _WebSeg;
        private string _Shrinkable;
        private string _SegName;
        private string _TitleHidden;
        private string _SegHidden;
        private string _IsCollapsed;

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes that the segment starts Collapsed"), DisplayNameAttribute("Collapsed")]
        public string IsCollapsed
        {
            get { return _IsCollapsed; }
            set
            {
                switch (value)
                {
                    case "1":
                        _IsCollapsed = "Yes";
                        break;
                    case "0":
                        _IsCollapsed = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes that the segment is hidden"), DisplayNameAttribute("Hidden")]
        public string SegHidden
        {
            get { return _SegHidden; }
            set
            {
                switch (value)
                {
                    case "1":
                        _SegHidden = "Yes";
                        break;
                    case "0":
                        _SegHidden = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes that the segment title is hidden"), DisplayNameAttribute("Title Hidden")]
        public string TitleHidden
        {
            get { return _TitleHidden; }
            set
            {
                switch (value)
                {
                    case "1":
                        _TitleHidden = "Yes";
                        break;
                    case "0":
                        _TitleHidden = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes the internal segment name"), DisplayNameAttribute("Segment Name")]
        public string SegName
        {
            get { return _SegName; }
            set { _SegName = value; }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes that the segment can be collapsed"), DisplayNameAttribute("Collapsable")]
        public string Shrinkable
        {
            get { return _Shrinkable; }
            set
            {
                switch (value)
                {
                    case "1":
                        _Shrinkable = "Yes";
                        break;
                    case "0":
                        _Shrinkable = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Web"), DescriptionAttribute("Denotes that the segment is a web segment"), DisplayNameAttribute("Web Segment")]
        public string WebSeg
        {
            get { return _WebSeg; }
            set
            {
                switch (value)
                {
                    case "1":
                        _WebSeg = "Yes";
                        break;
                    case "0":
                        _WebSeg = "No";
                        break;
                }
            }
        }
    }

    [DefaultPropertyAttribute("FullText")]
    public class propertyStatic
    {
        private string _FullText;
        private string _Hidden;
        private string _Type = "Static Text";

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes type of Form Field"), DisplayNameAttribute("Type")]
        public string Type
        {
            get { return _Type; }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes field is not displayed to user"), DisplayNameAttribute("Hidden")]
        public string Hidden
        {
            get { return _Hidden; }
            set
            {
                switch (value)
                {
                    case "0":
                        _Hidden = "Yes";
                        break;
                    case "1":
                        _Hidden = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Displays full text of Static text field"), DisplayNameAttribute("Full Text")]
        public string FullText
        {
            get { return _FullText; }
            set { _FullText = value; }
        }
    }

    [DefaultPropertyAttribute("ButtonName")]
    public class propertyButton
    {
        private string _ButtonName;
        private string _Hidden;
        private string _OnToolbar;
        private string _Type = "Button";

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes type of Form Field"), DisplayNameAttribute("Type")]
        public string Type
        {
            get { return _Type; }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes Button is displayed on Toolbar"), DisplayNameAttribute("On Toolbar")]
        public string OnToolbar
        {
            get { return _OnToolbar; }
            set
            {
                switch (value)
                {
                    case "1":
                        _OnToolbar = "Yes";
                        break;
                    case "0":
                        _OnToolbar = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes Button is Hidden"), DisplayNameAttribute("Hidden")]
        public string Hidden
        {
          get { return _Hidden; }
            set
            {
                switch (value)
                {
                    case "0":
                        _Hidden = "Yes";
                        break;
                    case "1":
                        _Hidden = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes internal name of Button"), DisplayNameAttribute("Button Name")]
        public string ButtonName
        {
            get { return _ButtonName; }
            set { _ButtonName = value; }
        }
    }

    [DefaultPropertyAttribute("Name")]
    public class propertyDisconn
    {
        private string _Name;
        private string _DictionaryName;
        private string _Type = "Disconnected";
        private string _Required ;

        public string Required
        {
          get { return _Required; }
            set
            {
                switch (value)
                {
                    case "1":
                        _Required = "Yes";
                        break;
                    case "0":
                        _Required = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Field"), DescriptionAttribute("This is a disconnected Field"), DisplayNameAttribute("Type")]
        public string Type
        {
            get { return _Type; }
        }

        [CategoryAttribute("Field"), DescriptionAttribute("Denotes Data Dictionary used"), DisplayNameAttribute("Dictionary")]
        public string DictionaryName
        {
            get { return _DictionaryName; }
            set { _DictionaryName = value; }
        }
        
        [CategoryAttribute("Field"), DescriptionAttribute("Denotes internal name of field"), DisplayNameAttribute("Field Name")]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

    }

    [DefaultPropertyAttribute("Name")]
    public class propertyIcon
    {
        private string _IconName;
        private string _Type = "Icon";
        private string _Tooltip;
        private string _Priority;
        private string _URL;

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes path to icon image"), DisplayNameAttribute("Icon URL")]
        public string URL
        {
            get { return _URL; }
            set { _URL = value; }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes position of icon if more than one displayed"), DisplayNameAttribute("Priority")]
        public string Priority
        {
            get { return _Priority; }
            set { _Priority = value; }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes text displayed to user when hovering"), DisplayNameAttribute("Tooltip")]
        public string Tooltip
        {
            get { return _Tooltip; }
            set { _Tooltip = value; }
        }

        public string Type
        {
            [CategoryAttribute("Display"), DescriptionAttribute("Denotes Type of Form Field"), DisplayNameAttribute("Type")]
            get { return _Type; }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes name of Icon"), DisplayNameAttribute("Name")]
        public string IconName
        {
            get { return _IconName; }
            set { _IconName = value; }
        }
    }


    [DefaultPropertyAttribute("FieldTitle")]
    public class propertyFormField
    {
        private string _FieldTitle;
        private string _Visible;
        private string _Required;
        private string _LineCount;
        private string _Type = "Field";
        private string _FieldName;
        private string _TableName;
        private object _FieldId;

        [BrowsableAttribute(false)]
        public object FieldId
        {
          get { return _FieldId; }
          set { _FieldId = value; }
        }

        [CategoryAttribute("Field"), DescriptionAttribute("Denotes name of Table field is associated with"), DisplayNameAttribute("SQL Table")]
        public string TableName
        {
            get { return _TableName; }
            set { _TableName = value; }
        }

        [CategoryAttribute("Field"), DescriptionAttribute("Denotes name of Database Field used"), DisplayNameAttribute("SQL Field")]
        public string FieldName
        {
            get { return _FieldName; }
            set { _FieldName = value; }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes type of Form Field)"), DisplayNameAttribute("Type")]
        public string Type
        {
            get { return _Type; }
        }
        

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes number of lines to display (for Memo fields)"), DisplayNameAttribute("Line Count")]
        public string LineCount
        {
            get { return _LineCount; }
            set { _LineCount = value; }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes the field is required to save record"), DisplayNameAttribute("Required")]
        public string Required
        {
            get { return _Required; }
            set
            {
                switch (value)
                {
                    case "1":
                        _Required = "Yes";
                        break;
                    case "0":
                        _Required = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes whether field is visible or not"), DisplayNameAttribute("Visible")]
        public string Visible
        {
            get { return _Visible; }
            set
            {
                switch (value)
                {
                    case "1":
                        _Visible = "Yes";
                        break;
                    case "0":
                        _Visible = "No";
                        break;
                }
            }
        }

        [CategoryAttribute("Display"), DescriptionAttribute("Denotes user displayed name of field"), DisplayNameAttribute("Field Title")]
        public string FieldTitle
        {
            get { return _FieldTitle; }
            set { _FieldTitle = value; }
        }
    }
    public class cboItem
    {
        public string Name;
        public string Key;

        public cboItem(string name, string key)
        {
            Name = name;
            Key = key;
        }
        public override string ToString()
        {
            return Name;
        }
    }
}
